<?php
define("S", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");

function commonDateFormat($time = null)
{
    is_null($time) && $time = time();
    return date('Y-m-d', $time);
}

function commonTimeFormat($time = null)
{
    is_null($time) && $time = time();
    return date('Y-m-d H:i:s', $time);
}

function getGoodName($goodId)
{
    return M("is_good")->where('id', $goodId)->getField("name");
}

function int2Str($number)
{
    $len = strlen(S);

    $str = "";
    while ($number != 0) {
        $mod = $number % $len;
        $div = intval(floor($number / $len));
        $str .= S[$mod];
        $number = $div;
    }

    return $str;
}

function str2Int($str)
{
    $int = 0;

    $len = strlen(S);
    for ($i = 0; $i < strlen($str); $i++) {
        $int += pow($len, $i) * strpos(S, $str[$i]);
    }

    return $int;
}
